pin = 1
gpio.mode(pin, gpio.OUTPUT)

--wifi
wifi.setmode(wifi.STATION)
def_sta_config = wifi.sta.getdefaultconfig(true)
for key, value in pairs(def_sta_config) do
    print(key .. ":" )
    print(value)
end
wifi.sta.autoconnect(1)
t1 = tmr.create()
i = 0
t1:register(
    3000,
    tmr.ALARM_AUTO,
    function(t)
        i = i + 1
        ip = wifi.sta.getip()
        print(ip)
        if ip ~= nil then
            --got ip,can next operate
            print("ok")
            t:unregister()
            dofile("ntp.lua")
        end
        if i > 10 then
            print("fail")
            t:unregister()
            dofile("smart.lua")
        end
    end
)
t1:start()
--
